package com.iwop.moto.service.impl;

import com.iwop.moto.controller.MpromotionController;
import com.iwop.moto.dao.MPromotionDao;
import com.iwop.moto.model.MPromotion;
import com.iwop.moto.model.SuperRecordModel;
import com.iwop.moto.service.MPromotionService;
import org.apache.ibatis.annotations.Param;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author czq
 * @version 1.0
 * @created 2017/2/14 0014.
 */
@Service
public class MPromotionServiceImpl implements MPromotionService {
    private Logger logger = Logger.getLogger(MPromotionServiceImpl.class);


    @Autowired
    private MPromotionDao mPromotionDao;

    @Override
    public MPromotion getSuperUserByFromUser(String fromUserId) {
        return mPromotionDao.getSuperUserByFromUser(fromUserId);
    }

    @Override
    public List<String> getChildUsersByhostUser(@Param("hostUserId") String hostUserId) {
        List<String > childUsers = mPromotionDao.getChildUsersByhostUser(hostUserId);
        return childUsers;
    }

    @Override
    public List<SuperRecordModel> findChildUserInfoByUserId(SuperRecordModel superRecordModel) {
        List childUserInfo = null;
        try {
            childUserInfo = mPromotionDao.findChildUserInfoByUserId(superRecordModel);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("获取下属用户信息异常");
        }
        return childUserInfo;
    }

    @Override
    public Long countPayMent(SuperRecordModel srModel) {
        Long aLong = mPromotionDao.countPayMent(srModel);
        return aLong;
    }


}
